/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package searchsort;

/**
 *
 * @author parallels
 */
public class BubbleSort {
    
    public static MyDataBeanArray sort(MyDataBeanArray myArray) {
         
        for (int pass = 0; pass <= myArray.size() - 2; ++pass) {
            for (int i = 0; i <= myArray.size() - pass - 2; ++i) {
                if (myArray.get(i).getKey() > myArray.get(i + 1).getKey()) {
                    MyDataBean temp = myArray.get(i);
                    myArray.set(i, myArray.get(i + 1));
                    myArray.set(i + 1, temp);
                }
            }
        }
        
        return myArray;
        
    }
    
}
